<?php  
  
namespace app\common\enum;  
  
abstract class MenuTypeEnum  
{  
    // 定义枚举值  
    const DIR = 1;  
    const MENU = 2;  
    const BUTTON = 3;  
  
    // 定义枚举描述  
    private static $descriptions = [  
        self::DIR => '目录',  
        self::MENU => '菜单',  
        self::BUTTON => '按钮',  
    ];  
  
    // 禁止实例化枚举类  
    private function __construct() {}  
  
    // 禁止克隆枚举类  
    private function __clone() {}  
  
    // 获取枚举值的描述  
    public static function getDescription($value)  
    {  
        return isset(self::$descriptions[$value]) ? self::$descriptions[$value] : '未知类型';  
    }  
  
    // 获取所有枚举值及其描述  
    public static function getAll()  
    {  
        return [  
            ['code'=>self::DIR, 'desc'=>self::$descriptions[self::DIR]], 
            ['code'=>self::MENU, 'desc'=>self::$descriptions[self::MENU]],
            ['code'=>self::BUTTON, 'desc'=>self::$descriptions[self::BUTTON]],
        ];  
    }   
}